package com.myfoon.model.entity;

import java.io.Serializable;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "PHOTO")
public class Photo implements Serializable {    
    private Long id;
    private User owner;
    private String src;
    private String srcsmall;
    private Timestamp created;
    private String tempId;
    
    public Photo() {
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    @Id 
    @GeneratedValue(generator = "PhotoSequence", strategy = GenerationType.AUTO)
    @SequenceGenerator(name = "PhotoSequence", allocationSize = 1, sequenceName = "PHOTO_SEQ_01")
    @Column(name = "ID", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    
    public void setOwner(User owner) {
        this.owner = owner;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "OWNER")
    public User getOwner() {
        return owner;
    }

    public void setSrc(String src) {
        this.src = src;
    }

    @Column(name = "SRC")
    public String getSrc() {
        return src;
    }

    public void setSrcsmall(String srcsmall) {
        this.srcsmall = srcsmall;
    }

    @Column(name = "SRC_SMALL")
    public String getSrcsmall() {
        return srcsmall;
    }

    public void setCreated(Timestamp created) {
        this.created = created;
    }

    @Column(name = "CREATED")
    public Timestamp getCreated() {
        return created;
    }

    public void setTempId(String tempId) {
        this.tempId = tempId;
    }

    @Transient
    public String getTempId() {
        return tempId;
    }
}
